/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgPrincipal;

import jgame.JGObject;
import jgame.JGTimer;

/**
 *
 * @author Mike
 */
public class JetPack extends JGObject
{

    private Mouton mouton;

    public JetPack(double coordX, double coordY)
    {
        super("jetPack", true, coordX, coordY, 5, "jetPack");
    }

    @Override
    public void hit(JGObject object)
    {
        // Si c'est un mouton
        if (object instanceof Mouton)
        {
            eng.playAudio("flying");
            mouton = (Mouton) object;

            mouton.setJetpack(true);

            if (mouton.getGraphic().equals("sheepLeft"))
            {
                mouton.setGraphic("sheepJetPackLeft");
            }
            else if (mouton.getGraphic().equals("sheepRight"))
            {
                mouton.setGraphic("sheepJetPackRight");
            }

            this.remove();

            new JGTimer(300, true)
            {

                @Override
                public void alarm()
                {
                    if (mouton.getGraphic().equals("sheepJetPackLeft"))
                    {
                        mouton.setGraphic("sheepLeft");
                    }
                    else if (mouton.getGraphic().equals("sheepJetPackRight"))
                    {
                        mouton.setGraphic("sheepRight");
                    }
                    mouton.setJetpack(false);
                }
            };
        }
    }
}
